ostbuild: Make binary snapshots an extension of source
authorColin Walters <walters@verbum.org>
Thu, 10 May 2012 23:07:54 +0000 (19:07 -0400)
committerColin Walters <walters@verbum.org>
Fri, 18 May 2012 20:30:44 +0000 (16:30 -0400)
This significantly simplifies things; we no longer need to retrieve
individual components via 'pull-components', etc.

Makefile-ostbuild.am
src/ostbuild/pyostbuild/builtin_bin_to_src.py [deleted file]
src/ostbuild/pyostbuild/builtin_build_components.py
src/ostbuild/pyostbuild/builtin_compose.py
src/ostbuild/pyostbuild/builtin_tree_to_bin.py [deleted file]
src/ostbuild/pyostbuild/builtin_tree_to_src.py [new file with mode: 0755]
src/ostbuild/pyostbuild/builtins.py
src/ostbuild/pyostbuild/main.py

index 1ee71503b149239ac99ce858d1a4475f2aeecf74..7a0f52bead0ff98547eee2bc512454a52649b4e1 100644 (file)
@@ -23,7 +23,6 @@ EXTRA_DIST += src/ostbuild/ostbuild.in
 pyostbuilddir=$(libdir)/ostbuild/pyostbuild
 pyostbuild_PYTHON =                                    \
        src/ostbuild/pyostbuild/buildutil.py            \
-       src/ostbuild/pyostbuild/builtin_bin_to_src.py   \
        src/ostbuild/pyostbuild/builtin_branch_prefix.py        \
        src/ostbuild/pyostbuild/builtin_build_components.py     \
        src/ostbuild/pyostbuild/builtin_checkout.py     \
@@ -38,7 +37,7 @@ pyostbuild_PYTHON =                                   \
        src/ostbuild/pyostbuild/builtin_prefix.py       \
        src/ostbuild/pyostbuild/builtin_resolve.py      \
        src/ostbuild/pyostbuild/builtin_modify_snapshot.py      \
-       src/ostbuild/pyostbuild/builtin_tree_to_bin.py  \
+       src/ostbuild/pyostbuild/builtin_tree_to_src.py  \
        src/ostbuild/pyostbuild/builtin_init.py \
        src/ostbuild/pyostbuild/builtin_status.py       \
        src/ostbuild/pyostbuild/builtins.py             \
diff --git a/src/ostbuild/pyostbuild/builtin_bin_to_src.py b/src/ostbuild/pyostbuild/builtin_bin_to_src.py
deleted file mode 100755 (executable)
index d50e911..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-# Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
-# http://people.gnome.org/~walters/docs/build-api.txt
-
-import os,sys,stat,subprocess,tempfile,re,shutil
-import argparse
-from StringIO import StringIO
-import json
-
-from . import builtins
-from .ostbuildlog import log, fatal
-from .subprocess_helpers import run_sync, run_sync_get_output
-from . import buildutil
-
-class OstbuildBinToSrc(builtins.Builtin):
-    name = "bin-to-src"
-    short_description = "Turn a binary snapshot into a source snapshot"
-
-    def __init__(self):
-        builtins.Builtin.__init__(self)
-
-    def bin_snapshot_to_src(self, bin_snapshot):
-        del bin_snapshot['00ostree-bin-snapshot-version']
-
-        src_snapshot = dict(bin_snapshot)
-        src_snapshot['00ostree-src-snapshot-version'] = 0
-
-        all_architectures = src_snapshot['architecture-buildroots'].keys()
-        # Arbitrarily take first architecture
-        first_arch = all_architectures[0]
-
-        bin_components = src_snapshot['components']
-        src_components = {}
-        src_snapshot['components'] = src_components
-        for archname,rev in bin_components.iteritems():
-            (name, arch) = archname.rsplit('/', 1)
-            if arch != first_arch:
-                continue
-            meta = dict(self.get_component_meta_from_revision(rev))
-            del meta['name']
-            src_components[name] = meta
-
-        for target in src_snapshot['targets']:
-            for content_item in target['contents']:
-                name = content_item['name']
-                rev = bin_components[name]
-                content_item['ostree-revision'] = rev
-
-        return src_snapshot
-
-    def execute(self, argv):
-        parser = argparse.ArgumentParser(description=self.short_description)
-        parser.add_argument('--prefix')
-        parser.add_argument('--bin-snapshot')
-
-        args = parser.parse_args(argv)
-        self.parse_config()
-        self.parse_bin_snapshot(args.prefix, args.bin_snapshot)
-
-        snapshot = self.bin_snapshot_to_src(self.bin_snapshot)
-        db = self.get_src_snapshot_db()
-        path = db.store(snapshot)
-        log("Source snapshot: %s" % (path, ))
-
-builtins.register(OstbuildBinToSrc)
index 010f4984ccfb24cf1a07e30546983158b5833613..126fe3eae6107b6c762f876b067581c8a13af9c2 100755 (executable)
@@ -178,7 +178,7 @@ class OstbuildBuildComponents(builtins.Builtin):
         bin_snapshot = dict(self.snapshot)
 
         del bin_snapshot['00ostree-src-snapshot-version']
-        bin_snapshot['00ostree-bin-snapshot-version'] = 0
+        bin_snapshot['00ostree-bin-snapshot-version'] = 1
 
         for target in bin_snapshot['targets']:
             base = target['base']
@@ -199,14 +199,14 @@ class OstbuildBuildComponents(builtins.Builtin):
             for architecture in component_architectures[name]:
                 component_refs.append('components/%s/%s' % (name, architecture))
 
-        new_components = {}
+        component_revisions = {}
         resolved_refs = self._resolve_refs(component_refs)
         for name,rev in zip(components.iterkeys(), resolved_refs):
             for architecture in component_architectures[name]:
                 archname = '%s/%s' % (name, architecture)
-                new_components[archname] = rev
+                component_revisions[archname] = rev
 
-        bin_snapshot['components'] = new_components
+        bin_snapshot['component-revisions'] = component_revisions
 
         path = self.get_bin_snapshot_db().store(bin_snapshot)
         log("Binary snapshot: %s" % (path, ))
@@ -218,6 +218,7 @@ class OstbuildBuildComponents(builtins.Builtin):
         parser.add_argument('--prefix')
         parser.add_argument('--src-snapshot')
         parser.add_argument('--compose', action='store_true')
+        parser.add_argument('--compose-only', action='store_true')
         parser.add_argument('--start-at')
         parser.add_argument('--shell-on-failure', action='store_true')
         parser.add_argument('--debug-shell', action='store_true')
@@ -276,11 +277,12 @@ class OstbuildBuildComponents(builtins.Builtin):
         else:
             start_at_index = 0
 
-        for component_name in build_component_order[start_at_index:]:
-            component = required_components[component_name]
-            architectures = component_architectures[component_name]
-            for architecture in architectures:
-                self._build_one_component(component_name, component, architecture)
+        if not args.compose_only:
+            for component_name in build_component_order[start_at_index:]:
+                component = required_components[component_name]
+                architectures = component_architectures[component_name]
+                for architecture in architectures:
+                    self._build_one_component(component_name, component, architecture)
 
         self._save_bin_snapshot(required_components, component_architectures)   
 
index dabb516bd2615ecf79a4d979d014896b0465cfa4..acc1ef7d3e083c7be68fd83cdbe35d76f808ac8f 100755 (executable)
@@ -41,7 +41,7 @@ class OstbuildCompose(builtins.Builtin):
         builtins.Builtin.__init__(self)
 
     def _compose_one_target(self, bin_snapshot, target):
-        components = bin_snapshot['components']
+        components = bin_snapshot['component-revisions']
         base = target['base']
         base_name = 'bases/%s' % (base['name'], )
         base_revision = target['base']['ostree-revision']
diff --git a/src/ostbuild/pyostbuild/builtin_tree_to_bin.py b/src/ostbuild/pyostbuild/builtin_tree_to_bin.py
deleted file mode 100755 (executable)
index f25f2e3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
-# http://people.gnome.org/~walters/docs/build-api.txt
-
-import os,sys,stat,subprocess,tempfile,re,shutil
-import argparse
-from StringIO import StringIO
-import json
-
-from . import builtins
-from .ostbuildlog import log, fatal
-from .subprocess_helpers import run_sync, run_sync_get_output
-from . import buildutil
-
-class OstbuildTreeToBin(builtins.Builtin):
-    name = "tree-to-bin"
-    short_description = "Turn a tree into a binary snapshot"
-
-    def __init__(self):
-        builtins.Builtin.__init__(self)
-
-    def execute(self, argv):
-        parser = argparse.ArgumentParser(description=self.short_description)
-        parser.add_argument('--prefix')
-        parser.add_argument('--tree')
-
-        args = parser.parse_args(argv)
-        self.parse_config()
-        if args.prefix:
-            self.prefix = args.prefix
-
-        if args.tree:
-            self.load_bin_snapshot_from_path(args.tree)
-        else:
-            self.load_bin_snapshot_from_current()
-
-        db = self.get_bin_snapshot_db()
-        path = db.store(self.bin_snapshot)
-        log("Binary snapshot: %s" % (path, ))
-
-builtins.register(OstbuildTreeToBin)
diff --git a/src/ostbuild/pyostbuild/builtin_tree_to_src.py b/src/ostbuild/pyostbuild/builtin_tree_to_src.py
new file mode 100755 (executable)
index 0000000..b2df3b1
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
+# http://people.gnome.org/~walters/docs/build-api.txt
+
+import os,sys,stat,subprocess,tempfile,re,shutil
+import argparse
+from StringIO import StringIO
+import json
+
+from . import builtins
+from .ostbuildlog import log, fatal
+from .subprocess_helpers import run_sync, run_sync_get_output
+from . import buildutil
+
+class OstbuildTreeToSrc(builtins.Builtin):
+    name = "tree-to-src"
+    short_description = "Turn a tree into a source snapshot"
+
+    def __init__(self):
+        builtins.Builtin.__init__(self)
+
+    def bin_snapshot_to_src(self, bin_snapshot):
+        del bin_snapshot['00ostree-bin-snapshot-version']
+
+        src_snapshot = dict(bin_snapshot)
+        src_snapshot['00ostree-src-snapshot-version'] = 0
+
+        return src_snapshot
+
+    def execute(self, argv):
+        parser = argparse.ArgumentParser(description=self.short_description)
+        parser.add_argument('--prefix')
+        parser.add_argument('--tree')
+
+        args = parser.parse_args(argv)
+        self.parse_config()
+        if args.prefix:
+            self.prefix = args.prefix
+
+        if args.tree:
+            self.load_bin_snapshot_from_path(args.tree)
+        else:
+            self.load_bin_snapshot_from_current()
+
+        snapshot = self.bin_snapshot_to_src(self.bin_snapshot)
+        db = self.get_src_snapshot_db()
+        path = db.store(snapshot)
+        log("Source snapshot: %s" % (path, ))
+
+builtins.register(OstbuildTreeToSrc)
index a167e9b014ebe559b849de5854a009ce551f1677..109be653c0b3a8282a90cf0f21ea05303afc9439 100755 (executable)
@@ -93,11 +93,13 @@ class Builtin(object):
         self.patchdir = os.path.join(self.workdir, 'patches')
 
     def load_bin_snapshot_from_path(self, path):
-        self.bin_snapshot_path = os.path.join(path, 'contents.json')
+        self.bin_snapshot_path = os.path.join(path, 'ostree-meta', 'contents.json')
+        if not os.path.exists(self.bin_snapshot_path):
+            self.bin_snapshot_path = os.path.join(path, 'contents.json')
         self.bin_snapshot = json.load(open(self.bin_snapshot_path))
         bin_ver = self.bin_snapshot['00ostree-bin-snapshot-version']
-        if bin_ver != 0:
-            fatal("Unhandled 00ostree-bin-snapshot-version \"%d\", expected 0", bin_ver)
+        if bin_ver != 1:
+            fatal("Unhandled 00ostree-bin-snapshot-version %r, expected 1" % (bin_ver, ))
 
     def load_bin_snapshot_from_current(self):
         if self.ostree_dir is None:
@@ -211,8 +213,8 @@ class Builtin(object):
             self.bin_snapshot_path = path
         self.bin_snapshot = json.load(open(self.bin_snapshot_path))
         bin_ver = self.bin_snapshot['00ostree-bin-snapshot-version']
-        if bin_ver != 0:
-            fatal("Unhandled 00ostree-bin-snapshot-version \"%d\", expected 0" % (bin_ver, ))
+        if bin_ver != 1:
+            fatal("Unhandled 00ostree-bin-snapshot-version %r, expected 1" % (bin_ver, ))
 
     def execute(self, args):
         raise NotImplementedError()
index 7f91e385106ab55ec3bc5223152757735d6e4622..1c01bbc813d660e20ed4a181bf26b42e1bc930ae 100755 (executable)
@@ -22,7 +22,6 @@ import sys
 import argparse
 
 from . import builtins
-from . import builtin_bin_to_src
 from . import builtin_build_components
 from . import builtin_branch_prefix
 from . import builtin_checkout
@@ -37,7 +36,7 @@ from . import builtin_privhelper_deploy_qemu
 from . import builtin_prefix
 from . import builtin_resolve
 from . import builtin_modify_snapshot
-from . import builtin_tree_to_bin
+from . import builtin_tree_to_src
 from . import builtin_init
 from . import builtin_status